package com.example.flutter_test_opengl_plugin.surface_view

import android.content.Context
import android.opengl.GLSurfaceView
import android.view.SurfaceHolder
import android.view.SurfaceView
import com.example.flutter_test_opengl_plugin.TriangleJNILib
import javax.microedition.khronos.egl.EGLConfig
import javax.microedition.khronos.opengles.GL10

class TriangleSurfaceView(context: Context?) : SurfaceView(context), SurfaceHolder.Callback{

    init {
        holder.addCallback(this)
    }
    override fun surfaceCreated(holder: SurfaceHolder) {
        TriangleJNILib.initEGL(holder.surface)
    }

    override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
        TriangleJNILib.renderTriangle()
    }

    override fun surfaceDestroyed(holder: SurfaceHolder) {
        TriangleJNILib.cleanup()
    }

}